home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
webmon_1
/
modmon.bas
< prev
next >
Wrap
BASIC Source File
|
1999-08-08
|
2KB
|
64 lines
Attribute VB_Name = "Module1"
Global intNoOfServers As Integer
Global blnRebooting(8) As Boolean
Option Explicit
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, _
ByVal dwReserved As Long) As Boolean
Public Const EWX_FORCE = 4
Public Const EWX_LOGOFF = 0
Public Const EWX_REBOOT = 2
Public Const EWX_SHUTDOWN = 1
Public Function SSetting(key As String, ByVal data As String)
SaveSetting "FastTrack", "Mon", key, data
End Function
Public Function LSetting(key As String) As String
LSetting = GetSetting("FastTrack", "Mon", key)
End Function
Sub RebootPC(ByVal vstrComputerName As String, _
ByVal vblnReboot As Boolean, Optional die As Boolean)
'*********************************************************
'purpose:reboot PC
'inputs:vstrComputerName-computer to reboot
' vblnReboot--whether or not to
' reboot, TRUE to reboot, FALSE to cancel
'explanation:requires shutdown.exe (from NT resource kit)
' only tested on NT
'*********************************************************
Dim strCommandLine As String
On Error GoTo reboot_error
'determine if rebooting or cacelling
If (vblnReboot <> False) Then
'reboot
strCommandLine = App.Path & "\shutdown.exe \\" & _
vstrComputerName
If die <> True Then strCommandLine = strCommandLine & " /R"
strCommandLine = strCommandLine & " /T:10 " & _
Chr(34) & "This server shutdown was bought to you curtosy of WebMon" & _
Chr(34) & " /C /Y"
Shell strCommandLine, vbNormalFocus
Else
'cancel reboot
strCommandLine = App.Path & "\shutdown.exe \\" & _
vstrComputerName & " /A /Y"
Shell strCommandLine, vbNormalFocus
End If
Exit Sub
reboot_error:
MsgBox ("Error sending reboot to server")
End Sub
Public Function LogIt(data As String)
Dim strLogPath As String
Dim intLogFile As Integer
strLogPath = App.Path & "\" & Format(Now, "dd mmm yyyy") & ".txt"
intLogFile = FreeFile
Open strLogPath For Append As #intLogFile
Print #intLogFile, "[" & Now & "]" & data
Close #intLogFile
End Function